# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
#   include condorworknode::login
class condorworknode::login (
  $serviceensure = "stopped",
){

  $condor_login_file = '/etc/condor/config.d/condor_login.conf'


  case $facts['os']['release']['major'] {
  '7': {
    yumrepo { "condor":
      baseurl => "http://${mirrorserver}/yum/condor/9.0/el${facts['os']['release']['major']}/release",
      descr => "condor",
      enabled => 1,
      gpgcheck => 0,
      priority => 20,
      before   => Yumrepo['site'],
    }

    $condor_pkg = [
      "condor-9.0.4-1.el7.x86_64",
      "condor-classads-9.0.4-1.el7.x86_64",
      "condor-kbdd-9.0.4-1.el7.x86_64",
      "condor-procd-9.0.4-1.el7.x86_64",
      "condor-externals-9.0.4-1.el7.x86_64",
      "python2-condor-9.0.4-1.el7.x86_64",
    ]
  }
  '9': {
    yumrepo { "condor":
      baseurl => "http://${mirrorserver}/yum/condor/repo/10.x/el${facts['os']['release']['major']}/x86_64/release",
      descr => "condor",
      enabled => 1,
      gpgcheck => 0,
      priority => 20,
      before   => Yumrepo['site'],
    }

    $condor_pkg = [
      "condor",
      "condor-classads",
      "condor-kbdd",
      "condor-procd",
      "condor-externals",
      "python3-condor",
      "python3-scitokens",
    ]
  }
  }




  package { $condor_pkg:
              ensure  => installed,
              require => Yumrepo['site'],
  } ->

  package { "condor-ui":
              ensure  => absent,
  } ->

  file { $condor_login_file:
    ensure   => file,
    owner    => 0,
    group    => 0,
    mode     => '0644',
    source   =>  "puppet:///modules/condorworknode/condor_login.conf",
    notify  => Exec['reconfig_condor']
  } ->

  service { "condor":
    ensure     => $serviceensure,
    hasstatus  => true,
    hasrestart => true,
    enable     => false,
  } ->

  file { "/etc/condor/wrapper":
    ensure   => directory,
    owner    => 0,
    group    => 0,
    mode     => '0755',
  } ->
  file { "/etc/condor/wrapper/exp_group.json":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/exp_group.json",
  }

  file { "/etc/condor/config.d/00-htcondor-9.0.config":
    ensure  => absent,
  }

  exec {'reconfig_condor':
    command      => "/usr/sbin/condor_reconfig",
    refreshonly  => true
  }

}
